<template>
    <div>
        <!--引用表格-->
        <BasicTable @register="registerTable" :rowSelection="rowSelection" :pagination="true" :loading="loading">

            <template #tableTitle>
                <a-button type="primary" v-auth="'slt:tmstock:flushstock'" @click="flushStock"
                    preIcon="lets-icons:search-alt"> 刷新库存</a-button>
            </template>
        </BasicTable>
    </div>
</template>
<script lang="ts" name="org.jeecg.modules.xl-xlCustomerStoreInfo" setup>
import { ref, reactive, computed, unref } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
import { columns, searchFormSchema } from './TmStockList.data';

import { listAll, listAsync, flushstock } from './TmStockList.api';
import { mapTableTotalSummary } from '/@/utils/common/compUtils';

const queryParam = reactive<any>({});
const loading = ref(false);
//注册table数据
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
    tableProps: {
        title: '快麦ERP库存',
        api: listAll,
        columns: columns,
        canResize: false,
        useSearchForm: true,
        showIndexColumn: true,
        showSummary: false,
        showActionColumn: false,
        //summaryFunc: onSummary,
        formConfig: {
            //labelWidth: 120,
            schemas: searchFormSchema,
            autoSubmitOnEnter: true,
            showAdvancedButton: false,
            fieldMapToNumber: [
            ],
            fieldMapToTime: [
            ],
        },
        beforeFetch: (params) => {
            return Object.assign(params, queryParam);
        },
    },
   
})

const [registerTable, { reload, setProps }, { rowSelection, selectedRowKeys }] = tableContext

function onSummary(tableData: Recordable[]) {
    const totals = mapTableTotalSummary(tableData, ['totalavailablestocksum'])
    return [totals];
}

async function flushStock() {
   loading.value = true;
    await flushstock().then(() => {
        loading.value = false;
        reload();
    }
    );

}


</script>

<style lang="less" scoped>
:deep(.ant-picker),
:deep(.ant-input-number) {
    width: 100%;
}
</style>